//
//  HSYSetWarningToneVCViewController.m
//  HSY
//
//  Created by 陈浩 on 2017/4/7.
//  Copyright © 2017年 金开门. All rights reserved.
//

#import "HSYSetWarningToneVCViewController.h"
#import "APPCenter.h"

@interface HSYSetWarningToneVCViewController ()

@property(nonatomic,strong)NSArray *datalist;

@end

@implementation HSYSetWarningToneVCViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self.titleButton setTitle:@"收款提示音" forState:UIControlStateNormal];

    self.datalist = @[@"收款提示音",@"不提示"];
    
    self.tableView.editing = YES;
    self.tableView.tableFooterView = [UIView new];
    self.tableView.allowsMultipleSelection = NO;
    
    BOOL NotTip = [APPCenter defaultCenter].paymentTone;
    
    if (NotTip) {
        [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:1] animated:NO scrollPosition:UITableViewScrollPositionNone];
    }else{
        [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionNone];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{
    return  YES;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 2;
}

-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
    return UITableViewCellEditingStyleDelete|UITableViewCellEditingStyleInsert;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
    
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"UITableViewCell"];
    }
    
    cell.textLabel.text = self.datalist[indexPath.row];
    
    return cell;    
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView reloadData];
    [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
    
    if (indexPath.row == 1) {
        [APPCenter defaultCenter].paymentTone = YES;
    }else{
        [APPCenter defaultCenter].paymentTone = NO;
    }
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
